package com.example.demo;


import java.io.Serializable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class usersBean implements Serializable {
    private String name;

    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;

    public usersBean(){
        name = "小明";
    }

    public void setName(String name, String pass) {
        System.out.println("写入数据库"+name+pass);
        this.name = name;
    }

    public String getName() {
        try {
            conn = connBean.getConn();
            stmt = conn.createStatement();
            String sql = "SELECT * FROM users";
            rs = stmt.executeQuery(sql);
            while (rs.next()){
                String name  = rs.getString("user_name");
                System.out.println(name);
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            connBean.closeDB(rs,stmt,conn);
        }
        return name;
    }


}